// 对象 解构赋值

let person = {
  firstName: '张',
  lastName: '三',
  name: '张三',
  age: 24,
  color: 'red',
  sayHi() {
    console.log('hello!')
  },
  fullName: undefined
  // fullName: '张三'
  // sayHi: function () {}
}

const { name, ...other } = person
console.log(name)
console.log(other)


// const { fullName = 'zhangsan' } = person
// const { fullName: full = 'zhangsan' } = person
// console.log(full)


// const { 属性: 变量 } = person
// const { firstName: f, lastName: l } = person
// console.log(f + l)

/*const { firstName, lastName } = person
console.log(firstName + lastName)
*/

// const { uname, color, age, sayHi } = person
// console.log(uname)
// console.log(color)
// console.log(age)
// sayHi()





// 数组 解构赋值
/*let arr = [1, '张三', [99], function () {
  console.log('hello')
}]*/

// let [a, b, [c], d] = arr
// let [a, b] = arr
// let [a, ,b] = arr
// ...Rest
// let [a, c, ...other] = arr

// let [a, b = 123] = ['hh']

// console.log(a)
// console.log(other)
// console.log(aaa)

// console.log(c)
// console.log(d)

// let [a, b, c] = []
// let [a, b, c] = 123
// console.log(a)

// let [a] = []
// let [a = 123] = ['hh']
// let [a, b = 123] = ['hh']
// let [a, b = '李四'] = ['张三', undefined]
// console.log(a)
// console.log(b)
/*
let x = '1';
let y = '99';

let temp = null
temp = x
x = y
y = temp

// 交换变量
[y, x] = [x, y]
console.log(x) // 99
console.log(y) // 1
*/

